<?php
class Image extends AppModel {

	var $name = 'Image';
	var $validate = array(
		'type' => array(
			'notEmpty' => array(
				'rule'    => 'notEmpty',
				'message' => 'This field cannot be empty'
			),
			'isImage' => array(
				'rule'    => '/^image/',
				'message' => 'File must be an image'
			)
		),
		'size'     => array('numeric'),
		'item_id'  => array('notEmpty'),

		'upload_image' => array(
			'rule'    => 'checkUploadedFile',
			'message' => 'File is not an image file'
		)
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
		'Item' => array(
			'className'  => 'Item',
			'foreignKey' => 'item_id',
			'conditions' => '',
			'fields'     => '',
			'order'      => ''
		)
	);

	function checkUploadedFile() {
		return preg_match('/^image/', $this->data['Image']['type']);
	}
}
?>